package com.edu.bean.test;

import com.edu.bean.Student;
import com.edu.bean.User;
import com.edu.dao.UserDao;
import com.edu.dao.impl.UserDaoImpl;
import com.edu.service.UserService;
import com.edu.controller.UserController;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MyTest2 {


    @Test
    public void test01(){
        ApplicationContext context = new ClassPathXmlApplicationContext("app.xml");
        System.out.println(context.getBean("stu"));

        UserController userController = context.getBean(UserController.class);
        userController.userLogin();

        UserService userService = context.getBean(UserService.class);
        userService.login();

        UserDao userDao = (UserDao) context.getBean(UserDaoImpl.class);
        userDao.selectUser();
    }

    @Test
    public void test02(){
        ApplicationContext context = new ClassPathXmlApplicationContext("app.xml");
        Student stu1 = context.getBean(Student.class);
        Student stu2 = context.getBean(Student.class);
        System.out.println(stu1 == stu2);
    }

    @Test
    public void test03(){
        ApplicationContext context = new ClassPathXmlApplicationContext("app.xml");
        Student stu = context.getBean(Student.class);
        System.out.println(stu);
        System.out.println(stu.getBook());
        System.out.println(stu.getStuSex().getBytes());
    }
}
